<?php


/**
 * Base class that represents a query for the 'damages' table.
 *
 *
 *
 * @method DamagesDamagesQuery orderById($order = Criteria::ASC) Order by the id column
 * @method DamagesDamagesQuery orderByCarDamageId($order = Criteria::ASC) Order by the car_damage_id column
 * @method DamagesDamagesQuery orderByDictDamageTypeId($order = Criteria::ASC) Order by the dict_damage_type_id column
 * @method DamagesDamagesQuery orderByDictDamageSpotId($order = Criteria::ASC) Order by the dict_damage_spot_id column
 * @method DamagesDamagesQuery orderByDictDamageScaleId($order = Criteria::ASC) Order by the dict_damage_scale_id column
 * @method DamagesDamagesQuery orderByIsMain($order = Criteria::ASC) Order by the is_main column
 * @method DamagesDamagesQuery orderByCreated($order = Criteria::ASC) Order by the created column
 * @method DamagesDamagesQuery orderByModified($order = Criteria::ASC) Order by the modified column
 *
 * @method DamagesDamagesQuery groupById() Group by the id column
 * @method DamagesDamagesQuery groupByCarDamageId() Group by the car_damage_id column
 * @method DamagesDamagesQuery groupByDictDamageTypeId() Group by the dict_damage_type_id column
 * @method DamagesDamagesQuery groupByDictDamageSpotId() Group by the dict_damage_spot_id column
 * @method DamagesDamagesQuery groupByDictDamageScaleId() Group by the dict_damage_scale_id column
 * @method DamagesDamagesQuery groupByIsMain() Group by the is_main column
 * @method DamagesDamagesQuery groupByCreated() Group by the created column
 * @method DamagesDamagesQuery groupByModified() Group by the modified column
 *
 * @method DamagesDamagesQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
 * @method DamagesDamagesQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
 * @method DamagesDamagesQuery innerJoin($relation) Adds a INNER JOIN clause to the query
 *
 * @method DamagesDamagesQuery leftJoinCarDamages($relationAlias = null) Adds a LEFT JOIN clause to the query using the CarDamages relation
 * @method DamagesDamagesQuery rightJoinCarDamages($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CarDamages relation
 * @method DamagesDamagesQuery innerJoinCarDamages($relationAlias = null) Adds a INNER JOIN clause to the query using the CarDamages relation
 *
 * @method DamagesDamagesQuery leftJoinDictDamageTypes($relationAlias = null) Adds a LEFT JOIN clause to the query using the DictDamageTypes relation
 * @method DamagesDamagesQuery rightJoinDictDamageTypes($relationAlias = null) Adds a RIGHT JOIN clause to the query using the DictDamageTypes relation
 * @method DamagesDamagesQuery innerJoinDictDamageTypes($relationAlias = null) Adds a INNER JOIN clause to the query using the DictDamageTypes relation
 *
 * @method DamagesDamagesQuery leftJoinDictDamageSpots($relationAlias = null) Adds a LEFT JOIN clause to the query using the DictDamageSpots relation
 * @method DamagesDamagesQuery rightJoinDictDamageSpots($relationAlias = null) Adds a RIGHT JOIN clause to the query using the DictDamageSpots relation
 * @method DamagesDamagesQuery innerJoinDictDamageSpots($relationAlias = null) Adds a INNER JOIN clause to the query using the DictDamageSpots relation
 *
 * @method DamagesDamagesQuery leftJoinDictDamageScale($relationAlias = null) Adds a LEFT JOIN clause to the query using the DictDamageScale relation
 * @method DamagesDamagesQuery rightJoinDictDamageScale($relationAlias = null) Adds a RIGHT JOIN clause to the query using the DictDamageScale relation
 * @method DamagesDamagesQuery innerJoinDictDamageScale($relationAlias = null) Adds a INNER JOIN clause to the query using the DictDamageScale relation
 *
 * @method DamagesDamages findOne(PropelPDO $con = null) Return the first DamagesDamages matching the query
 * @method DamagesDamages findOneOrCreate(PropelPDO $con = null) Return the first DamagesDamages matching the query, or a new DamagesDamages object populated from the query conditions when no match is found
 *
 * @method DamagesDamages findOneById(int $id) Return the first DamagesDamages filtered by the id column
 * @method DamagesDamages findOneByCarDamageId(int $car_damage_id) Return the first DamagesDamages filtered by the car_damage_id column
 * @method DamagesDamages findOneByDictDamageTypeId(int $dict_damage_type_id) Return the first DamagesDamages filtered by the dict_damage_type_id column
 * @method DamagesDamages findOneByDictDamageSpotId(int $dict_damage_spot_id) Return the first DamagesDamages filtered by the dict_damage_spot_id column
 * @method DamagesDamages findOneByDictDamageScaleId(int $dict_damage_scale_id) Return the first DamagesDamages filtered by the dict_damage_scale_id column
 * @method DamagesDamages findOneByIsMain(int $is_main) Return the first DamagesDamages filtered by the is_main column
 * @method DamagesDamages findOneByCreated(string $created) Return the first DamagesDamages filtered by the created column
 * @method DamagesDamages findOneByModified(string $modified) Return the first DamagesDamages filtered by the modified column
 *
 * @method array findById(int $id) Return DamagesDamages objects filtered by the id column
 * @method array findByCarDamageId(int $car_damage_id) Return DamagesDamages objects filtered by the car_damage_id column
 * @method array findByDictDamageTypeId(int $dict_damage_type_id) Return DamagesDamages objects filtered by the dict_damage_type_id column
 * @method array findByDictDamageSpotId(int $dict_damage_spot_id) Return DamagesDamages objects filtered by the dict_damage_spot_id column
 * @method array findByDictDamageScaleId(int $dict_damage_scale_id) Return DamagesDamages objects filtered by the dict_damage_scale_id column
 * @method array findByIsMain(int $is_main) Return DamagesDamages objects filtered by the is_main column
 * @method array findByCreated(string $created) Return DamagesDamages objects filtered by the created column
 * @method array findByModified(string $modified) Return DamagesDamages objects filtered by the modified column
 *
 * @package    propel.generator.damages.om
 */
abstract class DamagesBaseDamagesQuery extends ModelCriteria
{
    /**
     * Initializes internal state of DamagesBaseDamagesQuery object.
     *
     * @param     string $dbName The dabase name
     * @param     string $modelName The phpName of a model, e.g. 'Book'
     * @param     string $modelAlias The alias for the model in this query, e.g. 'b'
     */
    public function __construct($dbName = 'vgp_damages', $modelName = 'DamagesDamages', $modelAlias = null)
    {
        parent::__construct($dbName, $modelName, $modelAlias);
    }

    /**
     * Returns a new DamagesDamagesQuery object.
     *
     * @param     string $modelAlias The alias of a model in the query
     * @param     DamagesDamagesQuery|Criteria $criteria Optional Criteria to build the query from
     *
     * @return DamagesDamagesQuery
     */
    public static function create($modelAlias = null, $criteria = null)
    {
        if ($criteria instanceof DamagesDamagesQuery) {
            return $criteria;
        }
        $query = new DamagesDamagesQuery();
        if (null !== $modelAlias) {
            $query->setModelAlias($modelAlias);
        }
        if ($criteria instanceof Criteria) {
            $query->mergeWith($criteria);
        }

        return $query;
    }

    /**
     * Find object by primary key.
     * Propel uses the instance pool to skip the database if the object exists.
     * Go fast if the query is untouched.
     *
     * <code>
     * $obj  = $c->findPk(12, $con);
     * </code>
     *
     * @param mixed $key Primary key to use for the query
     * @param     PropelPDO $con an optional connection object
     *
     * @return   DamagesDamages|DamagesDamages[]|mixed the result, formatted by the current formatter
     */
    public function findPk($key, $con = null)
    {
        if ($key === null) {
            return null;
        }
        if ((null !== ($obj = DamagesDamagesPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
            // the object is alredy in the instance pool
            return $obj;
        }
        if ($con === null) {
            $con = Propel::getConnection(DamagesDamagesPeer::DATABASE_NAME, Propel::CONNECTION_READ);
        }
        $this->basePreSelect($con);
        if ($this->formatter || $this->modelAlias || $this->with || $this->select
         || $this->selectColumns || $this->asColumns || $this->selectModifiers
         || $this->map || $this->having || $this->joins) {
            return $this->findPkComplex($key, $con);
        } else {
            return $this->findPkSimple($key, $con);
        }
    }

    /**
     * Find object by primary key using raw SQL to go fast.
     * Bypass doSelect() and the object formatter by using generated code.
     *
     * @param     mixed $key Primary key to use for the query
     * @param     PropelPDO $con A connection object
     *
     * @return   DamagesDamages A model object, or null if the key is not found
     * @throws   PropelException
     */
    protected function findPkSimple($key, $con)
    {
        $sql = 'SELECT ID, CAR_DAMAGE_ID, DICT_DAMAGE_TYPE_ID, DICT_DAMAGE_SPOT_ID, DICT_DAMAGE_SCALE_ID, IS_MAIN, CREATED, MODIFIED FROM damages WHERE ID = :p0';
        try {
            $stmt = $con->prepare($sql);
            $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
            $stmt->execute();
        } catch (Exception $e) {
            Propel::log($e->getMessage(), Propel::LOG_ERR);
            throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
        }
        $obj = null;
        if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
            $obj = new DamagesDamages();
            $obj->hydrate($row);
            DamagesDamagesPeer::addInstanceToPool($obj, (string) $key);
        }
        $stmt->closeCursor();

        return $obj;
    }

    /**
     * Find object by primary key.
     *
     * @param     mixed $key Primary key to use for the query
     * @param     PropelPDO $con A connection object
     *
     * @return DamagesDamages|DamagesDamages[]|mixed the result, formatted by the current formatter
     */
    protected function findPkComplex($key, $con)
    {
        // As the query uses a PK condition, no limit(1) is necessary.
        $criteria = $this->isKeepQuery() ? clone $this : $this;
        $stmt = $criteria
            ->filterByPrimaryKey($key)
            ->doSelect($con);

        return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
    }

    /**
     * Find objects by primary key
     * <code>
     * $objs = $c->findPks(array(12, 56, 832), $con);
     * </code>
     * @param     array $keys Primary keys to use for the query
     * @param     PropelPDO $con an optional connection object
     *
     * @return PropelObjectCollection|DamagesDamages[]|mixed the list of results, formatted by the current formatter
     */
    public function findPks($keys, $con = null)
    {
        if ($con === null) {
            $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
        }
        $this->basePreSelect($con);
        $criteria = $this->isKeepQuery() ? clone $this : $this;
        $stmt = $criteria
            ->filterByPrimaryKeys($keys)
            ->doSelect($con);

        return $criteria->getFormatter()->init($criteria)->format($stmt);
    }

    /**
     * Filter the query by primary key
     *
     * @param     mixed $key Primary key to use for the query
     *
     * @return DamagesDamagesQuery The current query, for fluid interface
     */
    public function filterByPrimaryKey($key)
    {

        return $this->addUsingAlias(DamagesDamagesPeer::ID, $key, Criteria::EQUAL);
    }

    /**
     * Filter the query by a list of primary keys
     *
     * @param     array $keys The list of primary key to use for the query
     *
     * @return DamagesDamagesQuery The current query, for fluid interface
     */
    public function filterByPrimaryKeys($keys)
    {

        return $this->addUsingAlias(DamagesDamagesPeer::ID, $keys, Criteria::IN);
    }

    /**
     * Filter the query on the id column
     *
     * Example usage:
     * <code>
     * $query->filterById(1234); // WHERE id = 1234
     * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
     * $query->filterById(array('min' => 12)); // WHERE id > 12
     * </code>
     *
     * @param     mixed $id The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesDamagesQuery The current query, for fluid interface
     */
    public function filterById($id = null, $comparison = null)
    {
        if (is_array($id) && null === $comparison) {
            $comparison = Criteria::IN;
        }

        return $this->addUsingAlias(DamagesDamagesPeer::ID, $id, $comparison);
    }

    /**
     * Filter the query on the car_damage_id column
     *
     * Example usage:
     * <code>
     * $query->filterByCarDamageId(1234); // WHERE car_damage_id = 1234
     * $query->filterByCarDamageId(array(12, 34)); // WHERE car_damage_id IN (12, 34)
     * $query->filterByCarDamageId(array('min' => 12)); // WHERE car_damage_id > 12
     * </code>
     *
     * @see       filterByCarDamages()
     *
     * @param     mixed $carDamageId The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesDamagesQuery The current query, for fluid interface
     */
    public function filterByCarDamageId($carDamageId = null, $comparison = null)
    {
        if (is_array($carDamageId)) {
            $useMinMax = false;
            if (isset($carDamageId['min'])) {
                $this->addUsingAlias(DamagesDamagesPeer::CAR_DAMAGE_ID, $carDamageId['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($carDamageId['max'])) {
                $this->addUsingAlias(DamagesDamagesPeer::CAR_DAMAGE_ID, $carDamageId['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(DamagesDamagesPeer::CAR_DAMAGE_ID, $carDamageId, $comparison);
    }

    /**
     * Filter the query on the dict_damage_type_id column
     *
     * Example usage:
     * <code>
     * $query->filterByDictDamageTypeId(1234); // WHERE dict_damage_type_id = 1234
     * $query->filterByDictDamageTypeId(array(12, 34)); // WHERE dict_damage_type_id IN (12, 34)
     * $query->filterByDictDamageTypeId(array('min' => 12)); // WHERE dict_damage_type_id > 12
     * </code>
     *
     * @see       filterByDictDamageTypes()
     *
     * @param     mixed $dictDamageTypeId The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesDamagesQuery The current query, for fluid interface
     */
    public function filterByDictDamageTypeId($dictDamageTypeId = null, $comparison = null)
    {
        if (is_array($dictDamageTypeId)) {
            $useMinMax = false;
            if (isset($dictDamageTypeId['min'])) {
                $this->addUsingAlias(DamagesDamagesPeer::DICT_DAMAGE_TYPE_ID, $dictDamageTypeId['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($dictDamageTypeId['max'])) {
                $this->addUsingAlias(DamagesDamagesPeer::DICT_DAMAGE_TYPE_ID, $dictDamageTypeId['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(DamagesDamagesPeer::DICT_DAMAGE_TYPE_ID, $dictDamageTypeId, $comparison);
    }

    /**
     * Filter the query on the dict_damage_spot_id column
     *
     * Example usage:
     * <code>
     * $query->filterByDictDamageSpotId(1234); // WHERE dict_damage_spot_id = 1234
     * $query->filterByDictDamageSpotId(array(12, 34)); // WHERE dict_damage_spot_id IN (12, 34)
     * $query->filterByDictDamageSpotId(array('min' => 12)); // WHERE dict_damage_spot_id > 12
     * </code>
     *
     * @see       filterByDictDamageSpots()
     *
     * @param     mixed $dictDamageSpotId The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesDamagesQuery The current query, for fluid interface
     */
    public function filterByDictDamageSpotId($dictDamageSpotId = null, $comparison = null)
    {
        if (is_array($dictDamageSpotId)) {
            $useMinMax = false;
            if (isset($dictDamageSpotId['min'])) {
                $this->addUsingAlias(DamagesDamagesPeer::DICT_DAMAGE_SPOT_ID, $dictDamageSpotId['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($dictDamageSpotId['max'])) {
                $this->addUsingAlias(DamagesDamagesPeer::DICT_DAMAGE_SPOT_ID, $dictDamageSpotId['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(DamagesDamagesPeer::DICT_DAMAGE_SPOT_ID, $dictDamageSpotId, $comparison);
    }

    /**
     * Filter the query on the dict_damage_scale_id column
     *
     * Example usage:
     * <code>
     * $query->filterByDictDamageScaleId(1234); // WHERE dict_damage_scale_id = 1234
     * $query->filterByDictDamageScaleId(array(12, 34)); // WHERE dict_damage_scale_id IN (12, 34)
     * $query->filterByDictDamageScaleId(array('min' => 12)); // WHERE dict_damage_scale_id > 12
     * </code>
     *
     * @see       filterByDictDamageScale()
     *
     * @param     mixed $dictDamageScaleId The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesDamagesQuery The current query, for fluid interface
     */
    public function filterByDictDamageScaleId($dictDamageScaleId = null, $comparison = null)
    {
        if (is_array($dictDamageScaleId)) {
            $useMinMax = false;
            if (isset($dictDamageScaleId['min'])) {
                $this->addUsingAlias(DamagesDamagesPeer::DICT_DAMAGE_SCALE_ID, $dictDamageScaleId['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($dictDamageScaleId['max'])) {
                $this->addUsingAlias(DamagesDamagesPeer::DICT_DAMAGE_SCALE_ID, $dictDamageScaleId['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(DamagesDamagesPeer::DICT_DAMAGE_SCALE_ID, $dictDamageScaleId, $comparison);
    }

    /**
     * Filter the query on the is_main column
     *
     * Example usage:
     * <code>
     * $query->filterByIsMain(1234); // WHERE is_main = 1234
     * $query->filterByIsMain(array(12, 34)); // WHERE is_main IN (12, 34)
     * $query->filterByIsMain(array('min' => 12)); // WHERE is_main > 12
     * </code>
     *
     * @param     mixed $isMain The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesDamagesQuery The current query, for fluid interface
     */
    public function filterByIsMain($isMain = null, $comparison = null)
    {
        if (is_array($isMain)) {
            $useMinMax = false;
            if (isset($isMain['min'])) {
                $this->addUsingAlias(DamagesDamagesPeer::IS_MAIN, $isMain['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($isMain['max'])) {
                $this->addUsingAlias(DamagesDamagesPeer::IS_MAIN, $isMain['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(DamagesDamagesPeer::IS_MAIN, $isMain, $comparison);
    }

    /**
     * Filter the query on the created column
     *
     * Example usage:
     * <code>
     * $query->filterByCreated('2011-03-14'); // WHERE created = '2011-03-14'
     * $query->filterByCreated('now'); // WHERE created = '2011-03-14'
     * $query->filterByCreated(array('max' => 'yesterday')); // WHERE created > '2011-03-13'
     * </code>
     *
     * @param     mixed $created The value to use as filter.
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
     *              Empty strings are treated as NULL.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesDamagesQuery The current query, for fluid interface
     */
    public function filterByCreated($created = null, $comparison = null)
    {
        if (is_array($created)) {
            $useMinMax = false;
            if (isset($created['min'])) {
                $this->addUsingAlias(DamagesDamagesPeer::CREATED, $created['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($created['max'])) {
                $this->addUsingAlias(DamagesDamagesPeer::CREATED, $created['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(DamagesDamagesPeer::CREATED, $created, $comparison);
    }

    /**
     * Filter the query on the modified column
     *
     * Example usage:
     * <code>
     * $query->filterByModified('2011-03-14'); // WHERE modified = '2011-03-14'
     * $query->filterByModified('now'); // WHERE modified = '2011-03-14'
     * $query->filterByModified(array('max' => 'yesterday')); // WHERE modified > '2011-03-13'
     * </code>
     *
     * @param     mixed $modified The value to use as filter.
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
     *              Empty strings are treated as NULL.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesDamagesQuery The current query, for fluid interface
     */
    public function filterByModified($modified = null, $comparison = null)
    {
        if (is_array($modified)) {
            $useMinMax = false;
            if (isset($modified['min'])) {
                $this->addUsingAlias(DamagesDamagesPeer::MODIFIED, $modified['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($modified['max'])) {
                $this->addUsingAlias(DamagesDamagesPeer::MODIFIED, $modified['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(DamagesDamagesPeer::MODIFIED, $modified, $comparison);
    }

    /**
     * Filter the query by a related DamagesCarDamages object
     *
     * @param   DamagesCarDamages|PropelObjectCollection $carDamages The related object(s) to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   DamagesDamagesQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByCarDamages($carDamages, $comparison = null)
    {
        if ($carDamages instanceof DamagesCarDamages) {
            return $this
                ->addUsingAlias(DamagesDamagesPeer::CAR_DAMAGE_ID, $carDamages->getId(), $comparison);
        } elseif ($carDamages instanceof PropelObjectCollection) {
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }

            return $this
                ->addUsingAlias(DamagesDamagesPeer::CAR_DAMAGE_ID, $carDamages->toKeyValue('PrimaryKey', 'Id'), $comparison);
        } else {
            throw new PropelException('filterByCarDamages() only accepts arguments of type DamagesCarDamages or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the CarDamages relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return DamagesDamagesQuery The current query, for fluid interface
     */
    public function joinCarDamages($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('CarDamages');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'CarDamages');
        }

        return $this;
    }

    /**
     * Use the CarDamages relation CarDamages object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   DamagesCarDamagesQuery A secondary query class using the current class as primary query
     */
    public function useCarDamagesQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinCarDamages($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'CarDamages', 'DamagesCarDamagesQuery');
    }

    /**
     * Filter the query by a related DamagesDictDamageTypes object
     *
     * @param   DamagesDictDamageTypes|PropelObjectCollection $dictDamageTypes The related object(s) to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   DamagesDamagesQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByDictDamageTypes($dictDamageTypes, $comparison = null)
    {
        if ($dictDamageTypes instanceof DamagesDictDamageTypes) {
            return $this
                ->addUsingAlias(DamagesDamagesPeer::DICT_DAMAGE_TYPE_ID, $dictDamageTypes->getId(), $comparison);
        } elseif ($dictDamageTypes instanceof PropelObjectCollection) {
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }

            return $this
                ->addUsingAlias(DamagesDamagesPeer::DICT_DAMAGE_TYPE_ID, $dictDamageTypes->toKeyValue('PrimaryKey', 'Id'), $comparison);
        } else {
            throw new PropelException('filterByDictDamageTypes() only accepts arguments of type DamagesDictDamageTypes or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the DictDamageTypes relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return DamagesDamagesQuery The current query, for fluid interface
     */
    public function joinDictDamageTypes($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('DictDamageTypes');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'DictDamageTypes');
        }

        return $this;
    }

    /**
     * Use the DictDamageTypes relation DictDamageTypes object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   DamagesDictDamageTypesQuery A secondary query class using the current class as primary query
     */
    public function useDictDamageTypesQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinDictDamageTypes($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'DictDamageTypes', 'DamagesDictDamageTypesQuery');
    }

    /**
     * Filter the query by a related DamagesDictDamageSpots object
     *
     * @param   DamagesDictDamageSpots|PropelObjectCollection $dictDamageSpots The related object(s) to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   DamagesDamagesQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByDictDamageSpots($dictDamageSpots, $comparison = null)
    {
        if ($dictDamageSpots instanceof DamagesDictDamageSpots) {
            return $this
                ->addUsingAlias(DamagesDamagesPeer::DICT_DAMAGE_SPOT_ID, $dictDamageSpots->getId(), $comparison);
        } elseif ($dictDamageSpots instanceof PropelObjectCollection) {
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }

            return $this
                ->addUsingAlias(DamagesDamagesPeer::DICT_DAMAGE_SPOT_ID, $dictDamageSpots->toKeyValue('PrimaryKey', 'Id'), $comparison);
        } else {
            throw new PropelException('filterByDictDamageSpots() only accepts arguments of type DamagesDictDamageSpots or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the DictDamageSpots relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return DamagesDamagesQuery The current query, for fluid interface
     */
    public function joinDictDamageSpots($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('DictDamageSpots');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'DictDamageSpots');
        }

        return $this;
    }

    /**
     * Use the DictDamageSpots relation DictDamageSpots object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   DamagesDictDamageSpotsQuery A secondary query class using the current class as primary query
     */
    public function useDictDamageSpotsQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinDictDamageSpots($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'DictDamageSpots', 'DamagesDictDamageSpotsQuery');
    }

    /**
     * Filter the query by a related DamagesDictDamageScale object
     *
     * @param   DamagesDictDamageScale|PropelObjectCollection $dictDamageScale The related object(s) to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   DamagesDamagesQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByDictDamageScale($dictDamageScale, $comparison = null)
    {
        if ($dictDamageScale instanceof DamagesDictDamageScale) {
            return $this
                ->addUsingAlias(DamagesDamagesPeer::DICT_DAMAGE_SCALE_ID, $dictDamageScale->getId(), $comparison);
        } elseif ($dictDamageScale instanceof PropelObjectCollection) {
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }

            return $this
                ->addUsingAlias(DamagesDamagesPeer::DICT_DAMAGE_SCALE_ID, $dictDamageScale->toKeyValue('PrimaryKey', 'Id'), $comparison);
        } else {
            throw new PropelException('filterByDictDamageScale() only accepts arguments of type DamagesDictDamageScale or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the DictDamageScale relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return DamagesDamagesQuery The current query, for fluid interface
     */
    public function joinDictDamageScale($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('DictDamageScale');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'DictDamageScale');
        }

        return $this;
    }

    /**
     * Use the DictDamageScale relation DictDamageScale object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   DamagesDictDamageScaleQuery A secondary query class using the current class as primary query
     */
    public function useDictDamageScaleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinDictDamageScale($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'DictDamageScale', 'DamagesDictDamageScaleQuery');
    }

    /**
     * Exclude object from result
     *
     * @param   DamagesDamages $damages Object to remove from the list of results
     *
     * @return DamagesDamagesQuery The current query, for fluid interface
     */
    public function prune($damages = null)
    {
        if ($damages) {
            $this->addUsingAlias(DamagesDamagesPeer::ID, $damages->getId(), Criteria::NOT_EQUAL);
        }

        return $this;
    }

}
